package leo.weixin.entity.menu;

import leo.weixin.entity.menu.AbstractButton;
import leo.weixin.entity.menu.Button;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * 子菜单button
 * {
*             "name": "扫码",
*             "sub_button": [
*
*             ]
 *},
 */
@Data
@Accessors(chain = true)
public class SubButton extends AbstractButton {
    private List<AbstractButton> sub_button;

    /**
     * 将菜单按钮添加到sub_button中
     * @param b
     * @return
     */
    public SubButton add(AbstractButton b) {
        sub_button.add(b);
        System.out.println("子类的:" + getSub_button().size());
        return this;
    }

    public SubButton(String name, List<AbstractButton> sub_button) {
        setName(name);
        this.sub_button = sub_button ;
    }
    public SubButton(String name) {
        setName(name);
        sub_button = new ArrayList<>();
    }

}
